<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="vue-2.4.0.js"></script>
    <style>
        .v-enter,
        .v-leave-to {
            opacity: 0;
            transform: translateX(80px)
        }
        
        .v-enter-active,
        .v-leave-active {
            transition: all 1s ease
        }
    </style>
</head>

<body>
    <div id="app">
        <p v-text="text"></p>
        <p v-html="html"></p>
        <ul>
            <li v-for="(item,index) in list" v-bind:key="1">
                <span>{{item.name}}</span>
                <span>{{item.age}}</span>
                <span>{{item.sex}}</span>
            </li>
        </ul>
        <input type="button" @click="btn1" value="按钮">
        <span v-show="flag">楚虽三户,亡秦必楚</span> <br> 名称:
        <input type="text" v-model="val1">
        <button @click="add">添加</button>
        <ul>
            <transition-group>
                <li v-for="(item,index) in list" :key="index">
                    <span>{{item.name}}</span>
                    <span>{{item.age}}</span>
                    <span>{{item.sex}}</span>
                </li>
            </transition-group>

        </ul>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                val1: "",
                flag: true,
                text: "今天",
                html: "<p>明天</p>",
                msg: "后天",
                list: [{
                    id: 1,
                    name: "天明",
                    age: 14,
                    sex: "男",
                }, {
                    id: 2,
                    name: "少羽",
                    age: 16,
                    sex: "男",
                }, {
                    id: 3,
                    name: "石兰",
                    age: 15,
                    sex: "女"
                }]
            },
            methods: {
                btn1() {
                    this.flag = !this.flag
                },
                add() {
                    this.list.push({
                        // id: (this.list.length - 1) ++,
                        name: this.val1,
                        age: 15,
                        sex: "男"

                    })
                }
            }
        })
    </script>
</body>

</html>